<template>
  <div>
    <puplic-modal
      :publicVisible="publicVisible"
      :title="title"
      modalStyle="addEditSupportModal"
      width="840px"
      @cancel="cancel"
      @handleOk="handleOk"
    >
      <div slot="content" class="content flex">
        <div class="chose-wrap f1 flex">
          <!-- 法律 -->
          <div class="left flex column align-center">
            <div class="title">
              <div class="icon"></div>
              选择法律
            </div>

            <div class="f1 scollbar">
              <div
                v-for="(item, index) in lawList"
                :key="index"
                :class="targetClickBtn == index ? 'content-wrap-active' : 'none'"
                class="content-wrap text-overflow"
                @click="handleClick(index, item.id)"
              >
                《{{ item.regulationsName }}》
              </div>
            </div>
          </div>
          <!-- 条文 -->
          <div class="mid flex column align-center">
            <div class="title">
              <div class="icon"></div>
              选择条文
            </div>
            <div v-if="checkList.length > 0" class="f1 scollbar" style="min-width: 190px">
              <a-checkbox-group
                v-model="clickList"
                class="f1"
                style="width: 100%; padding-right: 20px"
                @change="checked"
              >
                <a-checkbox v-for="(item, index) in checkList" :key="index" :value="item.id" class="text-overflow">{{
                  item.articleNo
                }}</a-checkbox>
              </a-checkbox-group>
            </div>
            <div v-else class="f1 scollbar" style="color: #509eee; min-width: 190px">暂无条文,请先选择法律项！</div>
          </div>
          <!-- 展示条文 -->
          <div class="right flex column align-center">
            <div class="title">
              <div class="icon"></div>
              已选条文
            </div>
            <div v-if="articleList.length > 0" class="f1 scollbar" style="min-width: 342px">
              <div v-for="(item, index) in articleList" :key="index">
                <p class="accords-title" style="margin: 10px 0">{{ item.articleNo }}</p>
                <p class="context" v-html="item.articleContent"></p>
              </div>
            </div>
            <div v-else class="f1 scollbar" style="color: #509eee; min-width: 342px">请在先选择条文！</div>
          </div>
        </div>
      </div>
    </puplic-modal>
  </div>
</template>
<script>
import puplicModal from '@/components/publicModal'
import { deleteAction, getAction, downFile, getFileAccessHttpUrl } from '@/api/manage'
export default {
  components: { puplicModal },
  name: 'addEditSupportModal',
  data() {
    return {
      title: '选择法律依据',
      publicVisible: false,
      targetClickBtn: 0,
      lawList: [],
      checkList: [],
      clickList: [],
      articleList: [],
    }
  },
  mounted() {
    this.getAllLawList()
  },
  methods: {
    async getAllLawList() {
      let {
        result: { records },
      } = await getAction('regulations/regulations/page', { pageSize: 99999 })
      this.lawList = records
    },
    handleClick(target, id) {
      this.targetClickBtn = target
      this.getAllArticleList(id)
    },
    async getAllArticleList(id) {
      let {
        result: { records },
      } = await getAction('regulations/article/page', { pageSize: 99999, regulationsId: id })
      this.checkList = records
    },
    checked(checkedValue) {
      this.articleList = checkedValue.map((item) => this.checkList.filter((i) => i.id == item)[0])
    },
    show(records) {
      this.publicVisible = true
    },

    handleOk() {
      this.$emit('articleList', this.articleList)
      this.cancel()
    },
    cancel() {
      this.publicVisible = false
      this.articleList = []
      this.clickList = []
    },
  },
}
</script>
<style lang="less" scoped>
@import '~@/assets/less/common.less';

/deep/ .content {
  padding: 0 20px 20px 20px;
}
/deep/ .ant-checkbox-wrapper {
  height: 44px;
  width: 162px;
  line-height: 44px;
  border-bottom: 1px solid var(--theme-input-border);
  margin: 0;
}
/deep/ .ant-checkbox-wrapper > span {
  font-size: 14px;
  font-weight: 500;
  color: #1388ff;
}

.scollbar {
  overflow-y: scroll;
  &::-webkit-scrollbar {
    background: #07447e;
  }
  &::-webkit-scrollbar-thumb {
    background: #1163b8;
  }
}
.text-overflow {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chose-wrap {
  height: 470px;
  border-bottom: 3px solid #07447e;
  .title {
    width: 100%;
    display: flex;
    align-items: center;
    height: 50px;
    line-height: 50px;
    border-bottom: 2px solid #07447e;
    margin-bottom: 10px;
    .icon {
      width: 6px;
      height: 6px;
      background: #1388ff;
      margin-right: 5px;
      border-radius: 50%;
    }
    font-size: 14px;
    font-weight: 500;
    color: #1388ff;
  }

  .left {
    flex: 3;
    .content-wrap {
      width: 200px;
      height: 40px;
      line-height: 40px;
      background: var(--theme-container-bg);
      border-radius: 8px;
      font-size: 14px;
      font-weight: 500;
      color: #1388ff;
      margin-bottom: 10px;
      margin-right: 5px;
      cursor: pointer;
    }
    .content-wrap-active {
      background: #1388ff;
      color: #0b3763;
    }
  }
  .mid {
    flex: 2.5;
    margin-left: 20px;
  }
  .right {
    flex: 4.5;
    margin-left: 20px;
    font-size: 14px;
    .accords-title {
      font-weight: 500;
      color: #1388ff;
    }
    .context {
      font-weight: 400;
      color: #509eee;
    }
  }
}
</style>
